import React, { Component } from 'react';




export default  class Header extends Component {
    inputKeyUp = (event)=>{
        const {keyCode,target} =event
        if(keyCode !== 13) return
        if(target.value.trim() == ''){
            alert("不为空")
            return
        }
        let {onAddRow} = this.props
        onAddRow({
            id:Math.random().toString(),
            checked:false,
            name:target.value
        })
        target.value = ''
    }
    render() {
        return (
           <>

                <div>
                    <input 
                        onKeyUp={this.inputKeyUp}
                        placeholder='请输入,按Enter键提交'
                    />
                </div>
           </>
        );
    }
}

